package cn.tedu.boyou.mgrsite.controller;

import cn.tedu.boyou.acticle.service.IDestinationService;
import cn.tedu.boyou.common.query.DestinationQuery;
import cn.tedu.boyou.common.util.AjaxResult;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 目的地
 */
@Controller
@RequestMapping("/destination")
public class DestinationController {

    @Reference
    private IDestinationService destinationService;

    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo")DestinationQuery qo){
        model.addAttribute("pageInfo",destinationService.query(qo));
        model.addAttribute("toasts",destinationService.getToasts(qo.getParentId()));
        return "destination/list";
    }

    @RequestMapping("/changeHotValue")
    @ResponseBody
    public Object changeHotValue(Long id,Boolean hot){
        destinationService.changeHotValue(id ,hot);
        return new AjaxResult();
    }
    @RequestMapping("/delete")
    @ResponseBody
    public Object delete(Long id){
        destinationService.delete(id);
        return new AjaxResult();
    }

    @RequestMapping("/setInfo")
    @ResponseBody
    public Object setInfo(Long id, String info){
        destinationService.setInfo(id,info);
        return new AjaxResult();
    }
}
